package com.bwie.doctor.controller;

import com.bwie.common.core.domain.Result;
import com.bwie.doctor.domain.dto.AddGroupDTO;
import com.bwie.doctor.domain.dto.MessageRequest;
import com.bwie.doctor.domain.vo.DoctorGroupVo;
import com.bwie.doctor.domain.vo.GroupPatientVo;
import com.bwie.doctor.domain.vo.MessageResponse;
import com.bwie.doctor.service.DoctorPatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("doctorPatient")
public class DoctorPatientController {

    /**
     * 注入
     */
    @Autowired
    private DoctorPatientService service;

    /**
     * 上海云计算-维度健康-新建群发消息
     * 医生获得患者分组列表
     * @return
     */
    @GetMapping("getDoctorGroup")
    public Result<List<DoctorGroupVo>> getDoctorGroup(){
        //获得患者分组列表
        List<DoctorGroupVo> list = service.getDoctorGroup();
        //返回
        return Result.success(list);
    }

    /**
     * 上海云计算-维度健康-新建群发消息
     * 医生获得分组下患者列表
     * @return
     */
    @GetMapping("getGroupPatient/{id}")
    public Result<List<GroupPatientVo>> getGroupPatient(@PathVariable Integer id){
        //医生获得分组下患者列表
        List<GroupPatientVo> list = service.getGroupPatient(id);
        //返回
        return Result.success(list);
    }

    /**
     * 上海云计算-维度健康-新建群发消息
     * 医生删除分组
     * @param id
     * @return
     */
    @DeleteMapping("delGroup/{id}")
    public Result delGroup(@PathVariable Integer id){
        //医生删除分组
        service.delGroup(id);
        //返回
        return Result.success();
    }

    /**
     * 上海云计算-维度健康-新建群发消息
     * 医生添加分组
     * @return
     */
    @PostMapping("addGroup")
    public Result addGroup(@RequestBody AddGroupDTO addGroupDTO){
        //医生添加分组
        service.addGroup(addGroupDTO);
        //返回
        return Result.success();
    }

    /**
     * 上海云计算-维度健康-新建群发消息
     * 群发消息
     * @Param request
     */
    @PostMapping("insertMessage")
    public Result insertMessage(@RequestBody MessageRequest request) {
        service.insertMessage(request);
        return Result.success();
    }

    /**
     * 上海云计算-维度健康-新建群发消息
     * 查询历史群发消息
     * @Param
     * @return
     */
    @GetMapping("selectMessageHistory")
    public Result<List<MessageResponse>> selectMessageHistory() {

        return Result.success(service.selectMessageHistory());
    }
}